﻿using System;
using System.Collections.Generic;
using System.Text;
using HAVNet.Core.String;


namespace HAVNet.Intros.AST
{
    public class ASTTypeDeclInterface : ASTNamespaceTypeDecl
    {
        public bool isPartial { get; set; }
        public readonly ASTTypeParamList        typeParamList   = new ASTTypeParamList      ();
        public readonly ASTTypeNames            baseTypeNames   = new ASTTypeNames          ();
        public readonly ASTTypeConstraintList   constraints     = new ASTTypeConstraintList ();
        public readonly ASTMemberDeclsI members = new ASTMemberDeclsI();


        public override string ToString()
        {
            depth++;

            //  nonClassTypesMod    =
            //      newMod          |
            //      publicMod       | 
            //      protectedMod    | 
            //      internalMod     | 
            //      privateMod      |
            //      unsafeMod       ,

            string mods = "";

            if (Mods.has(modifiers, Mods.newMod         )) mods += "new ";
            if (Mods.has(modifiers, Mods.publicMod      )) mods += "public ";
            if (Mods.has(modifiers, Mods.protectedMod   )) mods += "protected ";
            if (Mods.has(modifiers, Mods.internalMod    )) mods += "internal ";
            if (Mods.has(modifiers, Mods.privateMod     )) mods += "private ";
            if (Mods.has(modifiers, Mods.unsafeMod      )) mods += "unsafe ";

            if (isPartial) mods += "partial ";

            string ret = (baseTypeNames.Count > 0) ?
                Strings.tab(depth) + mods + string.Format("interface {0}{1}: {2} {3}", name, typeParamList, baseTypeNames, constraints)
                :
                Strings.tab(depth) + mods + string.Format("interface {0}{1} {2}", name, typeParamList, constraints);

            ret += Environment.NewLine + Strings.tab(depth) + "{" + Environment.NewLine;
            ret += members.ToString();
            ret += Environment.NewLine + Strings.tab(depth) + "}" + Environment.NewLine;
            
            if (hasFinalComma)
                ret += ";";

            depth--;
            return ret;
        }
    }
}
